//Write a program in Java to demonstrate single inheritance, multilevel inheritance and
//hierarchical inheritance. real life example


// Base class: Vehicle
class Vehicle {
    String brand;

    Vehicle(String brand) {
        this.brand = brand;
    }

    void displayInfo() {
        System.out.println("Brand: " + brand);
    }
}

// Single Inheritance: Car inherits from Vehicle
class Car extends Vehicle {
    int numberOfDoors;

    Car(String brand, int numberOfDoors) {
        super(brand);
        this.numberOfDoors = numberOfDoors;
    }

    void displayCarInfo() {
        displayInfo();
        System.out.println("Number of Doors: " + numberOfDoors);
    }
}

// Multilevel Inheritance: ElectricCar inherits from Car
class ElectricCar extends Car {
    int batteryCapacity;

    ElectricCar(String brand, int numberOfDoors, int batteryCapacity) {
        super(brand, numberOfDoors);
        this.batteryCapacity = batteryCapacity;
    }

    void displayElectricCarInfo() {
        displayCarInfo();
        System.out.println("Battery Capacity: " + batteryCapacity + " kWh");
    }
}

// Hierarchical Inheritance: Bike inherits from Vehicle
class Bike extends Vehicle {
    boolean isElectric;

    Bike(String brand, boolean isElectric) {
        super(brand);
        this.isElectric = isElectric;
    }

    void displayBikeInfo() {
        displayInfo();
        System.out.println("Electric: " + isElectric);
    }
}

public class InheritanceExample {
    public static void main(String[] args) {
        // Single Inheritance
        Car car = new Car("Toyota", 4);
        car.displayCarInfo();

        System.out.println("-----------------");

        // Multilevel Inheritance
        ElectricCar electricCar = new ElectricCar("Tesla", 4, 75);
        electricCar.displayElectricCarInfo();

        System.out.println("-----------------");

        // Hierarchical Inheritance
        Bike bike = new Bike("Honda", false);
        bike.displayBikeInfo();
    }
}

